"""
Copyright (c) Cookie Yang. All right reserved.
"""
from bcc import BPF

# Define BPF program
bpf_txt = """

int hello_world_printk(void *ctx) {
    bpf_trace_printk("Hello World!\\n");
    return 0;
}
"""

# Load BPF program
bpf_ctx = BPF(text=bpf_txt)
bpf_ctx.attach_kprobe(event=bpf_ctx.get_syscall_fnname("sync"),
                      fn_name="hello_world_printk")

# Print header
print("%s" % "MESSAGE")

# Format output
while 1:
    try:
        bpf_ctx.trace_print(fmt="{5}")
    except KeyboardInterrupt:
        print()
        exit()
